<?php
/*
*CAUTION! Remove this file after deployment.
*/

require_once("Initializer.php");
require_once("GlobalSettings.php");


class InitializerController extends Zend_Controller_Action
{
    public function preDispatch()
	{	
	   if(GlobalSettings::DISABLE_INITIALIZER)
	   {
	      $this->_redirect("/");
	   }
	}
	
	
    public function indexAction()
    {  
       $this->view->message	.="Checking database...\n";
	   $this->view->message .= Initializer::showDatabaseList();
	   
	   $this->view->message .= "\n\nDirectory Checking...\n";
	   $this->view->message .= Initializer::checkDirs();
	   
	   phpinfo();
	   
       $this->render("index");
    }
	
	public function initdatabaseAction()
	{   
       $sql = $this->getRequest()->getParam("sql");
	   if($sql == "")
	   {
	      $this->view->message = "'url?sql=filename or sql statement' must be defined.";
	   }
	   else
	   {
	      $this->view->message = Initializer::InitBySql($sql);
       }		  
	   $this->render("index");
	}
	
	public function initallAction()
	{		
		$this->view->message = Initializer::InitByAllSqlFiles();
        $this->view->message .= Initializer::createDirs();		
		$this->render("index");			   	  
	}
	
}



